package com.dragon.repository.domain.vo;

import com.dragon.common.model.Update;
import com.dragon.common.util.BeanUtils;
import com.dragon.repository.entity.ProductUnit;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import javax.validation.constraints.NotNull;
import java.util.ArrayList;
import java.util.List;


/**
 * @author sy
 */
@Data
@ApiModel(value = "")
public class ProductUnitVO {

    private static final long serialVersionUID = 1L;

    @ApiModelProperty(value = "主id")
    private Integer id;

    @ApiModelProperty(value = "计量名称")
    private String name;

    @ApiModelProperty(value = "公司id")
    private Integer companyId;

    @ApiModelProperty(value = "是否启用：0禁用，1启用")
    private Integer state;


    @NotNull(groups = Update.class,message = "主键不能为空")
    public static ProductUnit convert(ProductUnitVO vo) {
        ProductUnit entity = new ProductUnit();
        BeanUtils.copyProperties(vo,entity);
        return entity;
    }
    public static List<ProductUnit> convertList(List<ProductUnitVO> list) {
        List<ProductUnit> resultList = new ArrayList<>();
        for (ProductUnitVO vo : list) {
            resultList.add(convert(vo));
        }
        return resultList;
    }
}
